﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sherwood.SignOn.Server.Models;
using Sherwood.SignOn.Server.Models.ViewModels;
using Sherwood.SignOn.Server.Models.Services;

namespace Sherwood.SignOn.Server.Controllers
{
    public class SignOutController : ControllerBase
    {
        /// <summary>
        /// SignOut action
        /// Signs out user and redirects user to login page.
        /// </summary>
        /// <returns></returns>
        [ValidateInput(false)]
        public ActionResult Index(SignInViewModel model)
        {
            UserSessionHelper.EndCurrentUserSession();
            string queryString = "";
            if (Request != null && Request.QueryString != null)
            {
                queryString = Request.QueryString.ToString();
                if (!queryString.StartsWith("?"))
                {
                    queryString = "?" + queryString;
                }
            }
            return Redirect("~/SignIn/" + queryString);
        }



    }
}
